home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 65.zip
/
BS1 part 65
/
Math Visin v2.1 disk 1.adf
/
Arexx.WB
/
Simple
/
AreaBetweenGraphs
< prev
next >
Wrap
Text File
|
1992-02-12
|
3KB
|
109 lines
/* AreaBetweenGraphs set up MathVision to find area of intersection 14-Nov-89 dh
One common textbook problem is the area between two functions. This
ARexx program is designed to simplify the setup of this type of problem.
First of all, the two functions are entered in function lines FB and FC.
For example, let us take the two functions "x/2+.5" and cos(x), and find
the area between them over the interval -3 to 1. In MathVision enter:
Xmin: -3
Xmax: 1
FB: x/2+.5 ' function 1
FC: cos(x) ' function 2
Then run this ARexx program. Watch the comment line as it runs, as it
informs you of what is happening. It plots both functions on the screen,
and gives you instructions for what to do next. Note that FA finds the
difference of the two functions.
Use Simple/Analyze to see where the difference is not zero. In this
example, the middle of the screen analyzes to zero, which means we got the
functions reversed. Simply edit FA so as to be Max(fc-fb,0).
Then use Area to find the area between the two functions. The min function
makes it pick up only the area of the intersection, between -2.24 and 0.6.
===========================================================================*/
ADDRESS "MathVision"
OPTIONS RESULTS
NUMERIC DIGITS 14
EditScreenToFront
/* see if user has his functions in FB and FC */
get fb
funb = result
get fc
func = result
IF (funb=='RESULT') & (func=='RESULT') THEN DO
F0 ""
FB '"Put the formula for the first graph here'
FC '"Put the formula for the second graph here'
EXIT
END
Comment1 ""
Comment2 ""
Comment3 ""
/* find range of Y which includes both graphs */
Comment1 "Finding Range of first function"
F0 "fb"
GuessYminYmax
Get Ymin; YMina = result
Get Ymax; YMaxa = result
Comment1 "Finding Range of second function"
F0 "fc"
GuessYminYmax
Get Ymin; YMinb = result
Get Ymax; YMaxb = result
miny = min(Ymina, Yminb)
maxy = max(Ymaxa, Ymaxb)
Ymin miny /* plot both graphs now */
Ymax maxy
Overplot T
EraseScreen
Comment1 "Plotting first function"
PlotScreenToFront
F0 "fb"
SimplePen 1
PlotSimple
Comment1 "Plotting second function"
F0 "fc"
SimplePen 2
PlotSimple
EditScreenToFront
F0 "FA"
Comment1 "Determining which graph is highest"
Get XMin; Minx = RESULT
Get XMax; Maxx = RESULT
FbAbove = 0 /* sample to see which graph is higher the most */
FcAbove = 0
DO i = 0 to 1 by .1
X MinX+i*(MaxX-MinX)
Get Eval "fb"
FbResult = RESULT
Get Eval "fc"
FcResult = RESULT
if (FbResult >= FcResult)
THEN FbAbove = FbAbove+1
ELSE FcAbove = FcAbove+1
END
if (FbAbove > FcAbove)
THEN fa 'max(fb-fc,0) "FB is higher than FC'
ELSE fa 'max(fc-fb,0) "FC is higher than FB'
Comment1 "now use AREA to find the area between the graphs"
Comment2 "Zoom in or out as needed to correctly frame the intersection"
Comment3 "and run the ARexx program again."